package homework;
class Draw {
    // 构建类
    private int Height;
    // 构造函数
    public Draw(int h) {
        this.Height = h;
    }
    // 画三角形
    public void drawTr() {
        for (int i = 1; i <= Height; ++i) {
            for (int j = 0; j < Height - i; ++j) {
                System.out.print(" ");
            }
            for (int j = 0; j < i * 2 - 1; ++j) {
                System.out.print("*");
            }
            System.out.println();
        }
    }
    // 画矩形
    public void drawRc() {
        int a = Height * 3 / 2;
        for (int i = 0; i < Height; ++i) {
            for (int j = 0; j < Height * 3 / 4 - a / 2; ++j) {
                System.out.print(" ");
            }
            for (int j = 0; j < a; ++j) {
                System.out.print("*");
            }
            System.out.println();
        }
    }
    // 画正方形
    public void drawSq() {
        for (int i = 1; i <= Height; ++i) {
            for (int j = 0; j < Height; ++j) {
                System.out.print("*");
            }
            System.out.println();
        }
    }
    // 画平行四边形
    public void drawPr() {
        int a = Height * 3 / 2;
        for (int i = 0; i < Height; ++i) {
            for (int j = 0; j < i; ++j) {
                System.out.print(" ");
            }
            for (int j = 0; j < a; ++j) {
                System.out.print("*");
            }
            System.out.println();
        }
    }
}
public class dr {
    public static void main(String[] args) {
        Draw draw = new Draw(6); // 设置高度为6
        // 输出各种图形
        System.out.println("Triangle:");
        draw.drawTr();
        System.out.println();
        System.out.println("Rectangle:");
        draw.drawRc();
        System.out.println();
        System.out.println("Square:");
        draw.drawSq();
        System.out.println();
        System.out.println("Parallelogram:");
        draw.drawPr();
        System.out.println();
    }
}
